<?php
/* 
 * Amnesia is Copyright (c) 2010 Mark Russell
 * 
 * Contact: info@amnesia-app.com	
 * 
 * This file is part of Amnesia.
 * 
 * Amnesia is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Amnesia is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Amnesia. If not, see <http://www.gnu.org/licenses/>.
 *
 */

include '../../db/db.php';

$user_id = mysql_real_escape_string ($_POST[user_id]);
$cat_name = mysql_real_escape_string ($_POST[cat_name]);

// Get the list
$query = "SELECT `" . $cat_name . "_id`,`title` FROM `" . $cat_name . "` WHERE `user_id`='" . $user_id . "' && live=\"1\"";

if(!($result = @ mysql_query ($query, $con)))
   showerror();

$result = mysql_query($query);

$xml = "";

while($array = mysql_fetch_array($result)) {

	$id = $array[$cat_name . '_id'];
	$title = $array['title'];
	
	$xml .= "<item>";
	$xml .= "<id>$id</id>";
	$xml .= "<title>$title</title>";
	$xml .= "</item>";
 
}

header('Content-Type: application/xml; charset=ISO-8859-1');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
echo "<list>";
echo $xml;
echo "</list>";

mysql_close($con);
?>